<HTML>
<HEAD>
<TITLE>DefaultProjectName - Create</TITLE>
<script type="text/javascript">
  var relPathToCommmon = "../../common/";
  var relPathToHelpDir = "../../common/help/";
</script>
<script type="text/javascript" src="../../common/jsdyn.js" language="JavaScript"></script>
<script type="text/javascript" src="../../common/js.js" language="JavaScript"></script>
<script type="text/javascript" src="leftmenu.js" language="JavaScript"></script>
<script type="text/javascript">
  var toSearchPage     = "_search','../../search";
  Body1();
</script>
<div class="headerPage">Create</div>
<div class="path"><a href="#" OnMouseOver="link('','../../index',this)" class="pathLink">OOXlib</A><img src="../../common/path-arrow.gif" class="path-arrow"><a href="#" OnMouseOver="link('_dir','include0',this)" class="pathLink">include</A><img src="../../common/path-arrow.gif" class="path-arrow"><a href="#" OnMouseOver="link('_class','CSimpleWindow4032',this)" class="pathLink">CSimpleWindow</A><img src="../../common/path-arrow.gif" class="path-arrow"><span class="pathNonLink">Create</span></div>
<script type="text/javascript">
 Body2();
 BodyLeftMenuStart();
WriteLeftMenu("","","","");
 BodyLeftMenuEnd();
 Body3();
</script>
<span class="tabInActive"><a href="#" OnMouseOver="linkTab('_member','Create4169101838','_description',this)" class="tabLinkInActive">Description</a></span>
<span class="tabActive"><a href="#" OnMouseOver="linkTab('_member','Create4169101838','_source',this)" class="tabLinkActive">Source</a></span>
<span class="tabInActive"><a href="#" OnMouseOver="linkTab('_member','Create4169101838','_callgraph',this)" class="tabLinkInActive">Call Graph</a></span>
<script type="text/javascript">
 Body4();
</script>
<div class="contentAirTop"></div>
<div class="paragraph2NoTopPadding">Start Line: 169</div>
<pre class="codeExamples">
void <a href="#" onMouseOver="link('_member','Create4169101838',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>void&nbsp;&nbsp;Create<BR>(const CScreen * pScreen, IWindow * pParentWindow, const CUInt2dRectangle & Rectangle, const unsigned int iEventMask, const IEventHandler * pEventHandler, const ::std::string & WindowName, const ::std::string & ClassName, const ::std::string & IconPath, const CColor * pBackgroundColor, const unsigned int iBorderWidth, const bool bIsResizeable, const bool bShowCursor)',CAPTION,'<strong>Brief description</strong><BR>Creates the window.');" onMouseOut="return nd();">OOXlib::CSimpleWindow::Create</a>(const CScreen *pScreen, IWindow *pParentWindow, const CUInt2dRectangle &amp;Rectangle, const unsigned int iEventMask, const IEventHandler *pEventHandler, const::std::string &amp;WindowName, const::std::string &amp;ClassName, const::std::string &amp;IconPath, const CColor *pBackgroundColor, const unsigned int iBorderWidth, const bool bIsResizeable, const bool bShowCursor)
                                                                                                              {
    // If window's parent is the root window, set the default window position to (0,0).
    // That's because the (0,0) values doesn't take any effect.
    unsigned int posX = 0u;
    unsigned int posY = 0;
    if(NULL != pParentWindow) {
        posX = Rectangle.GetPositionX();
        posY = Rectangle.GetPositionY();
    }
    // Get border's and background's pixels.
    unsigned long borderPixel = ::XBlackPixel(<a href="#" onMouseOver="link('_member','m_pXServerConnection2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>CXServerConnection *&nbsp;&nbsp;m_pXServerConnection ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_pXServerConnection</a>-&gt;Get(), pScreen-&gt;Get());
    unsigned long backgroundPixel = ::XWhitePixel(<a href="#" onMouseOver="link('_member','m_pXServerConnection2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>CXServerConnection *&nbsp;&nbsp;m_pXServerConnection ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_pXServerConnection</a>-&gt;Get(), pScreen-&gt;Get());
    if(NULL != pBackgroundColor) {
        backgroundPixel = pBackgroundColor-&gt;GetPixel();
    }
    // Create simple window.
    ::Window window;
    if(NULL == pParentWindow) {
        // Border width must be nil for the top-level windows!
        // XCreateSimpleWindow can generate BadAlloc, BadMatch, BadValue, and BadWindow errors.
        window = ::XCreateSimpleWindow(<a href="#" onMouseOver="link('_member','m_pXServerConnection2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>CXServerConnection *&nbsp;&nbsp;m_pXServerConnection ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_pXServerConnection</a>-&gt;Get(), ::XRootWindow(<a href="#" onMouseOver="link('_member','m_pXServerConnection2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>CXServerConnection *&nbsp;&nbsp;m_pXServerConnection ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_pXServerConnection</a>-&gt;Get(), pScreen-&gt;Get()), posX, posY, Rectangle.GetWidth(), Rectangle.GetHeight(), 0, borderPixel, backgroundPixel);
    } else {
        // XCreateSimpleWindow can generate BadAlloc, BadMatch, BadValue, and BadWindow errors.
        window = ::XCreateSimpleWindow(<a href="#" onMouseOver="link('_member','m_pXServerConnection2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>CXServerConnection *&nbsp;&nbsp;m_pXServerConnection ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_pXServerConnection</a>-&gt;Get(), pParentWindow-&gt;Get(), posX, posY, Rectangle.GetWidth(), Rectangle.GetHeight(), iBorderWidth, borderPixel, backgroundPixel);
    }
    // Set default window name, if the specified window name is empty.
    char* windowName = NULL;
    const char *wn = "OOXlib Simple Window";
    if(WindowName.empty()) {
        windowName = const_cast&lt;char*&gt;(wn);
    } else {
        windowName = const_cast&lt;char*&gt;(WindowName.c_str());
    }
    // Create properties from character strings.
    ::XTextProperty windowNameProperty, iconNameProperty;
    if(0 == ::XStringListToTextProperty(&amp;windowName, 1, &amp;windowNameProperty) || 0 == ::XStringListToTextProperty(&amp;windowName, 1, &amp;iconNameProperty)) {
        // XDestroyWindow() can generate a BadWindow error.
        ::XDestroyWindow(<a href="#" onMouseOver="link('_member','m_pXServerConnection2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>CXServerConnection *&nbsp;&nbsp;m_pXServerConnection ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_pXServerConnection</a>-&gt;Get(), window);
        <a href="#" onMouseOver="link('_member','OOXLib_THROW3402324798',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>define&nbsp;&nbsp;OOXLib_THROW&nbsp;&nbsp;(ctor_name )',CAPTION,'<strong>Brief description</strong><BR>The main OOXlib throw replacement macro.');" onMouseOut="return nd();">OOXLib_THROW</a>(CXStringListToTextPropertyException);
    }
    // Create size hints structure.
    // Position has no effect, if the window's parent is a root window.
    ::XSizeHints sizeHints;
    sizeHints.flags         = PPosition | PSize;
    sizeHints.x             = Rectangle.GetPositionX();
    sizeHints.y             = Rectangle.GetPositionY();
    sizeHints.width         = Rectangle.GetWidth();
    sizeHints.height        = Rectangle.GetHeight();
    if(!bIsResizeable) {
        // Min and max width and height are set to prevent window's resizing. In addition,
        // this hides the 'restore' button on the title bar of the window.
        sizeHints.flags = sizeHints.flags | PMinSize | PMaxSize;;
        sizeHints.min_width     = Rectangle.GetWidth();
        sizeHints.min_height    = Rectangle.GetHeight();
        sizeHints.max_width     = Rectangle.GetWidth();
        sizeHints.max_height    = Rectangle.GetHeight();
    }
    // Create window manager hints.
    ::XWMHints wmHints;
    if(IconPath.empty()) {
        wmHints.flags = StateHint | InputHint;
        wmHints.initial_state = NormalState;
        wmHints.input = True;
    } else {
        <a href="#" onMouseOver="link('_member','m_pIcon2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>CIcon *&nbsp;&nbsp;m_pIcon ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_pIcon</a> = new CIcon(m_pXServerConnection, pScreen, IconPath);
        wmHints.flags = StateHint | IconPixmapHint | IconMaskHint | IconWindowHint | InputHint;
        wmHints.initial_state = NormalState;
        wmHints.input = True;
        wmHints.icon_pixmap = <a href="#" onMouseOver="link('_member','m_pIcon2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>CIcon *&nbsp;&nbsp;m_pIcon ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_pIcon</a>-&gt;Get();
        wmHints.icon_mask = <a href="#" onMouseOver="link('_member','m_pIcon2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>CIcon *&nbsp;&nbsp;m_pIcon ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_pIcon</a>-&gt;GetMask();
        wmHints.icon_window = window;
    }
    // Create class hint.
    ::XClassHint classHints;
    char *className = NULL;
    const char *cn = "OOXlibSimpleWindow";
    if(ClassName.empty()) {
        className = const_cast&lt;char*&gt;(cn);
    } else {
        className = const_cast&lt;char*&gt;(ClassName.c_str());
    }
    // Class name is used to associate the resources with some class of applications.
    classHints.res_name = NULL;
    classHints.res_class = className;
    // Set properties.
    // XSetWMProperties can generate BadAlloc and BadWindow errors.
    ::XSetWMProperties(<a href="#" onMouseOver="link('_member','m_pXServerConnection2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>CXServerConnection *&nbsp;&nbsp;m_pXServerConnection ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_pXServerConnection</a>-&gt;Get(), window, &amp;windowNameProperty, &amp;iconNameProperty, NULL, 0, &amp;sizeHints, &amp;wmHints, &amp;classHints);
    if(NULL == pParentWindow) {
        if(NULL != pEventHandler) {
            // If we have an error handler, we create an atom for the window, whos parent is the root window.
            // It's necessary to allow the program to close itself. Otherwise, the window (and the process) will
            // be killed by the server, and that's not good.
            // XInternAtom can generate BadAlloc and BadValue errors.
            ::Atom atom = ::XInternAtom(<a href="#" onMouseOver="link('_member','m_pXServerConnection2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>CXServerConnection *&nbsp;&nbsp;m_pXServerConnection ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_pXServerConnection</a>-&gt;Get(), "WM_DELETE_WINDOW", false);
            // XSetWMProtocols can generate BadAlloc and BadWindow errors.
            // It returns zero - it fails, but we don't need to check, cause when the XSetWMProtocols functon fails,
            // window will be destroyed by the server.
            ::XSetWMProtocols(<a href="#" onMouseOver="link('_member','m_pXServerConnection2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>CXServerConnection *&nbsp;&nbsp;m_pXServerConnection ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_pXServerConnection</a>-&gt;Get(), window, &amp;atom, 1);
        }
        // If there is no event handler, we allow the sever to kill the process.
    } else {
        // If the window has a parent, we set to this window the 'transient for hint' property,
        // which will tell the window manager, that this window belongs to the parent window,
        // and must be handled as a part of it. (For example, the 'WM_DELETE_WINDOW' message will be passed to the parent window.)
        // XSetTransientForHint can generate BadAlloc and BadWindow errors.
        ::XSetTransientForHint(<a href="#" onMouseOver="link('_member','m_pXServerConnection2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>CXServerConnection *&nbsp;&nbsp;m_pXServerConnection ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_pXServerConnection</a>-&gt;<a href="#" onMouseOver="link('_member','Get2399971253',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>virtual Display *&nbsp;&nbsp;Get&nbsp;&nbsp;() const',CAPTION,'<strong>Brief description</strong><BR>Returns a pointer to the display structure.');" onMouseOut="return nd();">Get</a>(), window, pParentWindow-&gt;Get());
    }
    // If the cursor must be hidden - create the transparent cursor.
    if(!bShowCursor) {
        // Create the pixmap, that will be a mask, that hides the cursor. This pixmap will set as cursor pixmap.
        // XCreatePixmap can generate BadAlloc , BadDrawable , and BadValue errors.
        ::Pixmap cursorPixmap = ::XCreatePixmap(<a href="#" onMouseOver="link('_member','m_pXServerConnection2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>CXServerConnection *&nbsp;&nbsp;m_pXServerConnection ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_pXServerConnection</a>-&gt;Get(), ::XRootWindow(<a href="#" onMouseOver="link('_member','m_pXServerConnection2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>CXServerConnection *&nbsp;&nbsp;m_pXServerConnection ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_pXServerConnection</a>-&gt;Get(), pScreen-&gt;Get()), 1, 1, 1);
        // Create the color.
        ::XColor cursorColor;
        // Create the cursor with this pixmap and color.
        // XCreatePixmapCursor can generate BadAlloc and BadPixmap errors.
        ::Cursor cursorId = ::XCreatePixmapCursor(<a href="#" onMouseOver="link('_member','m_pXServerConnection2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>CXServerConnection *&nbsp;&nbsp;m_pXServerConnection ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_pXServerConnection</a>-&gt;Get(), cursorPixmap, cursorPixmap, &amp;cursorColor, &amp;cursorColor, 0, 0);
        // Set cursor attributes.
        // XDefineCursor can generate BadCursor and BadWindow errors.
        ::XDefineCursor(<a href="#" onMouseOver="link('_member','m_pXServerConnection2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>CXServerConnection *&nbsp;&nbsp;m_pXServerConnection ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_pXServerConnection</a>-&gt;Get(), window, cursorId);
        // XFreeCursor can generate a BadCursor error.
        ::XFreeCursor(<a href="#" onMouseOver="link('_member','m_pXServerConnection2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>CXServerConnection *&nbsp;&nbsp;m_pXServerConnection ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_pXServerConnection</a>-&gt;Get(), cursorId);
        // XFrePixmap can generate a BadPixmap error.
        ::XFreePixmap(<a href="#" onMouseOver="link('_member','m_pXServerConnection2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>CXServerConnection *&nbsp;&nbsp;m_pXServerConnection ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_pXServerConnection</a>-&gt;Get(), cursorPixmap);
        <a href="#" onMouseOver="link('_member','m_bShowCursor2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>bool&nbsp;&nbsp;m_bShowCursor ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_bShowCursor</a> = false;
    } else {
        // XCreateFontCursor can generate BadAlloc and BadValue errors.
        ::Cursor cursorId = ::XCreateFontCursor(<a href="#" onMouseOver="link('_member','m_pXServerConnection2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>CXServerConnection *&nbsp;&nbsp;m_pXServerConnection ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_pXServerConnection</a>-&gt;Get(), XC_top_left_arrow);
        // XDefineCursor can generate BadCursor and BadWindow errors.
        ::XDefineCursor(<a href="#" onMouseOver="link('_member','m_pXServerConnection2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>CXServerConnection *&nbsp;&nbsp;m_pXServerConnection ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_pXServerConnection</a>-&gt;Get(), window, cursorId);
        // XFreeCursor can generate a BadCursor error.
        ::XFreeCursor(<a href="#" onMouseOver="link('_member','m_pXServerConnection2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>CXServerConnection *&nbsp;&nbsp;m_pXServerConnection ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_pXServerConnection</a>-&gt;Get(), cursorId);
        <a href="#" onMouseOver="link('_member','m_bShowCursor2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>bool&nbsp;&nbsp;m_bShowCursor ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_bShowCursor</a> = true;
    }
    ::XFree(windowNameProperty.value);
    ::XFree(iconNameProperty.value);
    <a href="#" onMouseOver="link('_member','m_Window2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>::Window&nbsp;&nbsp;m_Window ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_Window</a> = window;
    <a href="#" onMouseOver="link('_member','m_pParentWindow2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>IWindow *&nbsp;&nbsp;m_pParentWindow ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_pParentWindow</a> = pParentWindow;
    <a href="#" onMouseOver="link('_member','m_Rectangle2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>CUInt2dRectangle&nbsp;&nbsp;m_Rectangle ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_Rectangle</a> = Rectangle;
    <a href="#" onMouseOver="link('_member','m_iEventMask2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>unsigned int&nbsp;&nbsp;m_iEventMask ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_iEventMask</a> = iEventMask;
    <a href="#" onMouseOver="link('_member','m_pEventHandler2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>IEventHandler *&nbsp;&nbsp;m_pEventHandler ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_pEventHandler</a> = pEventHandler;
    if(NULL != <a href="#" onMouseOver="link('_member','m_pParentWindow2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>IWindow *&nbsp;&nbsp;m_pParentWindow ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_pParentWindow</a>) {
        <a href="#" onMouseOver="link('_member','m_iId2399711695',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>size_t&nbsp;&nbsp;m_iId ',CAPTION,'<strong>Brief description</strong><BR>');" onMouseOut="return nd();">m_iId</a> = <a href="#" onMouseOver="link('_member','Register2402178989',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>size_t&nbsp;&nbsp;Register&nbsp;&nbsp;(IWindow * pWindow)',CAPTION,'<strong>Brief description</strong><BR>Registers the specified window as a child of the parent window.');" onMouseOut="return nd();">Register</a>(this);
    }
    // Callback method.
    <a href="#" onMouseOver="link('_member','OnCreate2315919823',this); overLibDiagram();return overlib('<strong>Syntax</strong><BR>void&nbsp;&nbsp;OnCreate&nbsp;&nbsp;()',CAPTION,'<strong>Brief description</strong><BR>OnCreate handler.');" onMouseOut="return nd();">OnCreate</a>();
}
</pre><div class="contentAirBottom"></div>
<script type="text/javascript">
 Body5();
Statistics("","","","","");
 Body6();
SetPageTab('_member','_source');
</script>
